<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
%>
<jsp:include page="/comm/header.jsp" />
<s:include value="/comm/menu.jsp" />
<script type="text/javascript">


$(function(){
	var obj = $("[name='broker']");
	for(var i in obj){
		obj.eq(i).bind("click", function(){
			var p = $(this).attr("p");
			var userId = p.slice(0, -1);
			var flag = p.slice(-1);
			follow(userId, flag);
		});
	}
	
	var obj = $("[name='hbroker']");
	for(var i in obj){
		obj.eq(i).bind("click", function(){
			var p = $(this).attr("p");
			var userId = p.slice(0, -1);
			var flag = p.slice(-1);
			follow(userId, flag);
		});
	}
	
	$("#btnSearch").click(function() {
		$("#search").submit();
	});

	setTab('tabe',3,3);
}); 

	<%-- var bLogin = false;
	var fUserId = 0;
	var doLogin = function(){
		var mail = $("#amail").val();
		var pwd = $("#apwd").val();
		
		if(!mail && !pwd){
			$("#msg").html("<font color='red'>请输入您的登录邮箱和密码</font>");
			return;
		}
		
		if(!mail){
			$("#msg").html("<font color='red'>请输入您的登录邮箱</font>");
			return;
		}
		
		if(!pwd){
			$("#msg").html("<font color='red'>请输入您的密码</font>");
			return;
		}
		
		$.ajax({
			type:"POST",
			url:"aLogin.htm",
			data:{email:mail, pwd:pwd},
			datatype:"text",
			success:function(data){
				if(data == ""){
					$("#msg").html("<font color='red'>用户名或者密码错误!</font>");
				}else{
					bLogin = true;
					follow(fUserId, 4);
					closeLogin();
					$("#welcome").html("您好，"+data+"&nbsp;&nbsp;<a style='color:#A10000' href='<%=path%>/logout.htm'>退出登录</a>");
				}
		    }
		});
	}; --%>
	
	var follow = function(userId, flag){
		var userObj = "${sessionScope.user}";
		if(userObj == '' && !bLogin){
			to = 4;
			fUserId = userId;
			showLogin();
		}else{
			$.ajax({
				type:"POST",
				url:"follow.htm",
				data:{userId:userId, flag:flag},
				datatype:"text",
				success:function(data){
					if(4==flag){
						var array = data.split("#");
						if(""!=array[0]){
							var arr = array[0].split("|");
							for(var i in arr){
								$("#h"+arr[i]).attr("p", array[i]+"2");
								$("#h"+arr[i]).children().attr("src", "images/bg_butb1.png");
							}
						}
						if(""!=array[1]){
							var arr = array[1].split("|");
							for(var i in arr){
								$("#"+arr[i]).attr("p", array[i]+"2");
								$("#"+arr[i]).children().attr("src", "images/bg_butb1.png");
							}
						}
					}else{
						if(data == "true"){
							if(1==flag){
								$("#h"+userId).attr("p", userId+"2");
								$("#h"+userId).children().attr("src", "images/bg_butb1.png");
								$("#"+userId).attr("p", userId+"2");
								$("#"+userId).children().attr("src", "images/bg_butb1.png");
							}else{
								$("#h"+userId).attr("p", userId+"1");
								$("#h"+userId).children().attr("src", "images/bg_butb.png");
								$("#"+userId).attr("p", userId+"1");
								$("#"+userId).children().attr("src", "images/bg_butb.png");
							}
						}
				    }
				}
			});
		}
	};
	
	
	
	
	function query(type, value) {
		if (type == 1) {
			$("#categoryId").val(value);
		}else if (type == 2) {
			$("#areaId").val(value);
		}
		$("#search").submit();
	}
	
	function page(pageNum) {
		$("#superPage").val(pageNum);
		$("#search").submit();
		
	}
	
	function setPageSize(pageSize) {
		$("#pageSize").val(pageSize);
		$("#search").submit();
	}

	function sort(order) {
		$("#order").val(order);
		$("#search").submit();
	}

</script>

<div class="clear"></div>
  
<!--第1部分开始  --> 
    <div class="wrap1">
    	<div class="blank1"></div>
    	<s:form action="broker" method="get" id="search">
    	<s:hidden id="categoryId" name="category" />
		<s:hidden id="areaId" name="area" />
    	<s:hidden id="pageSize" name="pageSize" />
    	<s:hidden id="order" name="o" />
    	<input type="hidden" id="superPage" name="superPage" value="1" />
        <div class="outbox2">
        	<div class="sort_list1">
            	<ul>
            		<li>
						【类别】 
						<s:iterator value="cateList">
            				&nbsp;&nbsp;
            				<s:if test="categoryId==category">
								<span class="span21"><s:property value="categoryName" /></span>
							</s:if>
							<s:else>
								<a
									href="javascript:query(1, <s:property value='categoryId' />)"><s:property
											value="categoryName" /></a>
							</s:else>
						</s:iterator>
					</li>
					<li>
					   【区域】 <s:iterator value="areaList">
            			&nbsp;&nbsp;
            			<s:if test="areaId == area">
								<span class="span21"><s:property value="areaName" /></span>
							</s:if>
							<s:else>
								<a
									href="javascript:query(2, <s:property value='areaId' />);">&nbsp;&nbsp;<s:property
											value="areaName" /></a>
							</s:else>
						</s:iterator>
					</li>
                </ul>
            </div>
        	<div class="bg_line2">
        		<div class="span22">输入关键字：</div>
            	<div class="searchbox1"><s:textfield name="q" cssClass="input2" />	<input id="btnSearch" type="button" value="搜索" class="input3""/></div>
            	<div class="span23"><input name="" type="button" value="重置所有条件" class="input4" onclick="javascript:window.location.href='broker.htm'"/></div>
            	<div class="clear"></div>
        	</div>
        </div>     
        </s:form>
        <div class="blank1"></div>
    </div>
<!--第1部分结束  --> 

<!--第2部分开始  --> 

<div class="wrap1">

<!--左边开始  -->
	<div class="wrap_left">
    	<div class="w_box1">
<!--开始 -->
        <div class="outbox2">
        	<div class="agent_show_tt">
            	<span class="span24">共有 <span class="showtxt4"><s:property value='totalSize' /></span> 位经纪人 </span>
            	<span class="span25"><strong>排序：</strong>
            	<s:if test="order == 1">
            		人气&nbsp;&nbsp;|&nbsp;&nbsp;<a href="javascript:sort(2)">服务星级</a>
            	</s:if>
            	<s:else>
            		<a href="javascript:sort(1)">人气</a>&nbsp;&nbsp;|&nbsp;&nbsp;服务星级
            	</s:else>
            	&nbsp;&nbsp;
            	<s:if test="pageSize == 10">
            		10&nbsp;&nbsp;<a href="javascript:setPageSize(20);">20</a>&nbsp;&nbsp;<a href="javascript:setPageSize(30);">30</a>	
            	</s:if>
            	<s:elseif test="pageSize == 20">
            		<a href="javascript:setPageSize(10);">10</a>&nbsp;&nbsp;20&nbsp;&nbsp;<a href="javascript:setPageSize(30);">30</a>
            	</s:elseif>
            	<s:elseif test="pageSize == 30">
            		<a href="javascript:setPageSize(10);">10</a>&nbsp;&nbsp;<a href="javascript:setPageSize(20);">20</a>&nbsp;&nbsp;30
            	</s:elseif>
            	<s:else>
            		<a href="javascript:setPageSize(10);">10</a>&nbsp;&nbsp;<a href="javascript:setPageSize(20);">20</a>&nbsp;&nbsp;;<a href="javascript:setPageSize(30);">30</a>
            	</s:else>
            	</span>
            </div>
            <div class="clear"></div>
            
<!--列表开始-->
<s:iterator value="brokerList">        
 <div class="agent_box3">
 	<div class="wrap_left" style="margin-left:12px;">
 		<span class="span26"><a target="_blank" href="<%=path%>/brokerDetail.htm?id=${userid}"><img src="${photoUrl}"
					border="0" width="60" height="60"/></a><br />
					<img src="images/${starImg}"/>
        </span>
	</div>
 	<div class="wrap_left" style=" width:230px;">
    	<span class="span27">
 			<a target="_blank" href="<%=path%>/brokerDetail.htm?id=${userid}"><span class="span28">${nickName}</span></a><br />
        	代购行业:<s:iterator value="cateList" status="status">
        				<s:if test="#status.index<5">
						${categoryName}&nbsp;
						</s:if>
					</s:iterator><br />
			代购区域：<s:iterator value="areaList" status="status">
						<s:if test="#status.index<5">
						${areaName}&nbsp;
						</s:if>
					</s:iterator><br />
			<s:if test="followId==0">
   				<a id="${userid}" name="broker" p="${userid}1" style="cursor:pointer"><img src="images/bg_butb.png" align="absmiddle"/></a>
   			</s:if>
   			<s:else>
   				<a id="${userid}" name="broker" p="${userid}2" style="cursor:pointer"><img src="images/bg_butb1.png" align="absmiddle"/></a>
   			</s:else>
         	 &nbsp;已有 ${followCount}位关注者
         </span>
    </div>
    <div class="wrap_left">
    
    	<div class="agent_box_wrap2">
        	<div class="span29">最近代购</div>
        	<ul>
        	<s:iterator value="canBuyList">
        	<li style="width:310px; white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><a href="<%=path%>/canBuyDetail.htm?id=${canId}">${goodsName}</a></li>
        	</s:iterator>
            </ul>
		</div>
    </div>
    
    <div class="clear"></div>
 </div>
</s:iterator>
 
<!--列表结束-->
            
        </div>   
<!--结束 --> 
<!--页码开始-->
<div class="page_box">
<div class="pagewrap">
	<div class="page">
    	<s:if test="totalSize > 0">
						<ul>
							<s:if test="superPage == 1">
								<li>首页</li>
								<li>上一页</li>
							</s:if>
							<s:else>
								<li><a href="javascript:page(1)">首页</a></li>
								<li><a href="javascript:page(<s:property value='superPage' /> - 1)">上一页</a></li>
							</s:else>
							<s:iterator value="pageList">
								<s:if test="pageNumber == '...'">
									<li><s:property value='pageNumber' /></li>
								</s:if>
								<s:elseif test="choose">
									<li class="thisclass"><s:property value='pageNumber' /></li>
								</s:elseif>
								<s:else>
									<li><a href="javascript:page(<s:property value='pageNumber' />)"><s:property value='pageNumber' /></a></li>
								</s:else>
								
							</s:iterator>
							<s:if test="superPage == totalPage">
								<li>下一页</li>
								<li>末页</li>
							</s:if>
							<s:else>
								<li><a href="javascript:page(<s:property value='superPage' /> + 1)">下一页</a></li>
								<li><a href="javascript:page(<s:property value='totalPage' />)">末页</a></li>
							</s:else>
							<li><span class="pageinfo">共 <strong><s:property value='totalPage' /></strong>页<strong><s:property value='totalSize' /></strong>条
							</span></li>
							<div class="clear"></div>
						</ul>
			</s:if>
	</div>
</div>

</div>
<!--页码结束 -->
   
        </div>
    
    </div>
<!--左边结束  -->
<!--右边开始  -->
    <div class="wrap_right">
		<div class="w_box2">

			<div class="list_tt1">
                <div class="wrap_left"><span class="span6">代购经纪人排行榜</span></div>
                <div class="clear"></div>
            </div>
            <div class="right_listbox1">
                    
<!--经纪人排行榜选项卡开始 -->
<div id="tabbox3">
		<ul>
			<li id="tabc1" onclick="setTab('tabc',1,3)" class="hover"><a>总榜</a></li>
 		</ul>
</div>
 <div id="conten3">

 		<div class="tabc_show" id="con_tabc_1">
        
<!-- 经纪人列表开始 --> 

<div class="show_list3">

<!-- 循环开始 --> 
<s:iterator value="hotBrokerList">
		<li style="margin-bottom:10px;">
			<div class="wrap_left">
				<span class="showpic2"><a target="_blank" href="<%=path%>/brokerDetail.htm?id=${userid}"><img src="${photoUrl}"
					border="0" width="60" height="60"/></a></span>
			</div>
			<div class="wrap_left">
     			<span class="showtxt2"><a target="_blank" href="<%=path%>/brokerDetail.htm?id=${userid}"><span>${nickName}</span></a><br /><img src="images/${starImg}" border="0"/><br />
     			<s:if test="followId==0">
     				<a id="h${userid}" name="hbroker" p="${userid}1" style="cursor:pointer"><img src="images/bg_butb.png" border="0"/></a>
     			</s:if>
     			<s:else>
     				<a id="h${userid}" name="hbroker" p="${userid}2" style="cursor:pointer"><img src="images/bg_butb1.png" border="0"/></a>
     			</s:else>
     			</span>
     		</div>
     		<div class="wrap_right">
		     	<span class="showtxt3">
				代购行业：<s:iterator value="cateList" status="status">
        				<s:if test="#status.index<2">
						${categoryName}&nbsp;
						</s:if>
					</s:iterator><br />
		        代购区域：<s:iterator value="areaList" status="status">
		        		<s:if test="#status.index<2">
						${areaName}&nbsp;
						</s:if>
					</s:iterator><br />
		        关注：<span class="showtxt4">${followCount}</span>
		        </span>
        </div>
        <div class="clear"></div>
		</li>
	</s:iterator>
<!-- 循环结束 --> 
</div>

<!-- 经纪人列表结束 --> 
        
        
        
        </div>
        <div class="tabc_show" id="con_tabc_2">2</div>
        <div class="tabc_show" id="con_tabc_3">3</div>

        
</div>
        
        


<!--经纪人排行榜选项卡结束 -->           
                    
                    
                    	
                    </div>
            
            
            

        </div>
    </div>
<!--右边结束  -->
    
    <div class="clear"></div>
</div>

<!--第2部分结束  --> 
<jsp:include page="/comm/bottom.jsp" />
